// @description 人户表--账户管理
// @author yurui
// @createDate 2020.09.06
// @version v1.0.0
import { defHttp } from '/@/utils/http/axios';
import { ApiCommon  } from '../common'
import { UploadFileParams } from '/#/axios';

const { ADMIN_USER_DICT_API, CUSTOMER_ADMIN_API, METER_ADMIN_API, CHARGE_API, UPLOAD_URL } = ApiCommon;
// v1.0/metering/admin/meter/page
const NEW_ADMIN_USER_DICT_API = `${ADMIN_USER_DICT_API}/user`;
const ADMIN_USER_API = `${CUSTOMER_ADMIN_API}/user`;
const ADMIN_USER_REGION_DICT_API = `${ADMIN_USER_DICT_API}/region`;
const CONTACT_LIST_API = `${CUSTOMER_ADMIN_API}/contact`;

enum Api {
  USER_INFO = '/info', //查询账户详情
  USER_PARAMS = '/params',//获取用户列表相关参数
  USER_PAGE = '/page',//分页查询账户列表
    USER_LIST = '/list', // 根据账户编号查询
    REGION_LIST='/list',//省市区联动对应表
    CONTACT_QUERY='/list/query',//条件查询联系人
    USER_LOGOFF = '/user/logoff',//注销
    USER_CREATE = '/create',//创建
    UPDATE = '/update',//修改
    BIND_CONTACT = '/bind/contact',//绑定账户
    UNBIND_METER = '/unbind/meter',//账户解绑水表
    UNBIND_CONTACT = '/unbind/contact',//账户解绑联系人
    USER_CHANGE_HOUSEHOLDER = '/user/change/householder',//更换户主
    COMPANY_LIST_QUERY = '/company/list/query', //条件查询企业
    BIND_METER = '/bind/meter',//账户绑定水表
    USER_TAG = '/user-tag/all',//账户绑定水表
    USER_GET_CUSTOMER_USER_RECORD = '/getCustomerUserRecord', //获取该账户的所有业务记录数量
    CHECK_EXIST = '/check/exist', //获取该账户的所有业务记录数量
    METER_CHECK = '/check/exist/', //获取该账户的所有业务记录数量
    WITHHOLDING_RECORD = '/withholding/admin/record-detail/changxing/page/', //综合业务办理平台-分页获取用户所有代扣记录
    BANK_LIST = '/bank-contact/list/', // 获取用户银行代扣签约账户信息列表,
    BATCH_INSERT_EXCEL = '/batch-insert/excel', // 立户批量入库
  }

/**
 * @description: 请求的API地址
 */
//查询账户详情
export const userInfoApi = (params: object) => defHttp.get({ url: ADMIN_USER_API + Api.USER_INFO, params });
//获取用户列表相关参数
export const userParamsApi = () => defHttp.get({ url: NEW_ADMIN_USER_DICT_API + Api.USER_PARAMS });
//获取用户标签枚举
export const userTagApi = () => defHttp.get({ url: CUSTOMER_ADMIN_API + Api.USER_TAG });
//分页查询账户列表
export const userPageApi = (params: object) => defHttp.get({ url: ADMIN_USER_API + Api.USER_PAGE, params });
// 根据账户编号查询
export const userListApi = (params: object) => defHttp.get({ url: ADMIN_USER_API + Api.USER_LIST, params });
//分页查询账户列表
export const regionListApi = (params: object) => defHttp.get({ url: ADMIN_USER_REGION_DICT_API + Api.REGION_LIST, params });
//条件查询联系人
export const contactQueryApi = (params: object) => defHttp.get({ url: CONTACT_LIST_API + Api.CONTACT_QUERY, params });
//获取物理水表分页
export const meteringAdminApi = (params: object) => defHttp.get({ url: METER_ADMIN_API + Api.USER_PAGE, params });
//创建物理水表
export const meteringCreateApi = (params: object) => defHttp.post({ url: METER_ADMIN_API + Api.USER_CREATE, params });
//注销
export const userLogoffApi = (params: object) => defHttp.get({ url: CUSTOMER_ADMIN_API + Api.USER_LOGOFF, params });
//创建账户
export const createApi = (params: object) => defHttp.post({ url: ADMIN_USER_API + Api.USER_CREATE, params });
//修改账户
export const updateApi = (params: object) => defHttp.post({ url: ADMIN_USER_API + Api.UPDATE, params });
//添加联系人
export const userContactCreateApi = (params: object) => defHttp.post({ url: CONTACT_LIST_API + Api.USER_CREATE, params });
//添加是否存在
export const isContactApi = (params: object) => defHttp.get({ url: CONTACT_LIST_API + Api.CHECK_EXIST, params });
//账户绑定联系人
export const bindContactApi = (params: object) => defHttp.post({ url: ADMIN_USER_API + Api.BIND_CONTACT, params });
//更换户主
export const userChangeHouseholderApi = (params: object) => defHttp.post({ url: CUSTOMER_ADMIN_API + Api.USER_CHANGE_HOUSEHOLDER, params });
//条件查询企业
export const companyListQueryApi = (params: object) => defHttp.get({ url: CUSTOMER_ADMIN_API + Api.COMPANY_LIST_QUERY, params });
//账户解绑水表
export const unbindMeterApi = (params:object) => defHttp.get({ url: ADMIN_USER_API + Api.UNBIND_METER, params });
//账户解绑联系人
export const unbindContactApi = (params:object) => defHttp.get({ url: ADMIN_USER_API + Api.UNBIND_CONTACT, params });
//水表是否存在
export const isMeterApi = (code: string) => defHttp.get({ url: METER_ADMIN_API + Api.METER_CHECK + code });
//账户绑联水表
export const bindMeterApi = (params:object) => defHttp.post({ url: ADMIN_USER_API + Api.BIND_METER, params });
// 获取该账户的所有业务记录数量
export const getCustomerUserRecordApi = (params:object) => defHttp.post({ url: ADMIN_USER_API + Api.USER_GET_CUSTOMER_USER_RECORD, params }); 
export const getWithholdingRecordApi = (data: object) =>
  defHttp.post({ url: CHARGE_API + Api.WITHHOLDING_RECORD, data }); // 综合业务办理平台-分页获取用户所有代扣记录

export const getBankListApi = (params: any) =>
  defHttp.get({ url: CUSTOMER_ADMIN_API + Api.BANK_LIST + params.user_id }); // 获取用户银行代扣签约账户信息列表

export const batchInsertExcelApi = (params: UploadFileParams, onUploadProgress: (progressEvent: ProgressEvent) => void,) => defHttp.uploadFile({ 
  url: UPLOAD_URL +  CUSTOMER_ADMIN_API + Api.BATCH_INSERT_EXCEL,
  onUploadProgress
}, params);
